package com.example.web.controller;

import com.example.web.service.CouponStrategy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.Map;

@RestController
@Slf4j
public class SettlementController {

    @Autowired
    private Map<String, CouponStrategy> couponStrategyMap;

    @RequestMapping("/settle")
    public ResponseEntity settle(String type) {
        CouponStrategy couponStrategy = couponStrategyMap.get(type);
        BigDecimal calculate = couponStrategy.calculate(BigDecimal.valueOf(10L));
        log.info("calculate:{}",calculate);
        return ResponseEntity.ok().build();
    }

}
